﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simple.Repository.Models.Article
{
    /// <summary>
    /// 文章管理表
    /// </summary>
    public class ArticleManage : BusinessFullEntityBase<Guid>
    {

        /// <summary>
        /// 文章标题
        /// </summary>
        public string Title { get; set; } = "";

        /// <summary>
        /// 分类Id
        /// </summary>
        public Guid? CategoryId { get; set; }

        /// <summary>
        /// 文章是否是否显示
        /// </summary>
        public bool? IsShow { get; set; } = true;

        /// <summary>
        /// 显示区域 1-家长，2园务
        /// </summary>
        [MaxLength(50)]
        public string? ShowRange { get; set; } = "";

        /// <summary>
        /// 文章内容
        /// </summary>
        public string ArticleContent { get; set; } = "";

        /// <summary>
        /// 阅读数量
        /// </summary>
        public int ReadCount { get; set; } = 0;

        /// <summary>
        /// 分类信息
        /// </summary>
        public ArticleCategory? ArticleCategory = null;

        /// <summary>
        /// 文章图片集合
        /// </summary>
        public List<ArticleManageImage>? Images = null;

        public override void ConfigureEntity(ModelBuilder builder)
        {
            builder.Entity<ArticleManage>(entity =>
            {
                entity.ToTable("Article");
                entity.HasOne(c => c.ArticleCategory).WithMany(c => c.ArticleManages).HasForeignKey(c => c.CategoryId);
            });
        }
    }
}
